/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * jifAdministrarParametros.java
 *
 * Created on 07-dic-2010, 16:21:59
 */

package Suministros;

import administracion.helper.Listas;
import administracion.helper.Utiles_Tabla;
import java.util.ArrayList;
import java.util.List;
import org.jdesktop.beansbinding.AutoBinding;
import org.jdesktop.beansbinding.BindingGroup;
import org.jdesktop.beansbinding.ELProperty;
import org.jdesktop.swingbinding.JTableBinding;
import org.jdesktop.swingbinding.SwingBindings;
import suministros.ejb30.entity.Parametros;

/**
 *
 * @author Diana
 */
public class jifAdministrarParametros extends javax.swing.JInternalFrame {
    List<Parametros> listaParametros= new ArrayList<Parametros>();
    private BindingGroup bindingGroup;
    private JTableBinding jTableBinding;
    /** Creates new form jifAdministrarParametros */
    public jifAdministrarParametros() {
        initComponents();

        cargarDatosTabla();
    }
     public void cargarDatosTabla(){

    listaParametros= Listas.getParametros();
    this.bindingGroup = new BindingGroup();
    this.jTableBinding = SwingBindings.createJTableBinding(AutoBinding.UpdateStrategy.READ, this.listaParametros, this.jTable1);


    JTableBinding.ColumnBinding columnBinding0 = this.jTableBinding.addColumnBinding(ELProperty.create("${idParametro}"));

    columnBinding0.setColumnName("ID");
    columnBinding0.setColumnClass(String.class);
    columnBinding0.setEditable(false);

    JTableBinding.ColumnBinding columnBinding1 = this.jTableBinding.addColumnBinding(ELProperty.create("${param1}"));

    columnBinding1.setColumnName("param1");
    columnBinding1.setColumnClass(String.class);
    columnBinding1.setEditable(false);

    JTableBinding.ColumnBinding columnBinding2 = this.jTableBinding.addColumnBinding(ELProperty.create("${param2}"));

    columnBinding2.setColumnName("param2");
    columnBinding2.setColumnClass(String.class);
    columnBinding2.setEditable(false);

    JTableBinding.ColumnBinding columnBinding3 = this.jTableBinding.addColumnBinding(ELProperty.create("${param3}"));

    columnBinding3.setColumnName("param3");
    columnBinding3.setColumnClass(String.class);
    columnBinding3.setEditable(false);

     JTableBinding.ColumnBinding columnBinding31 = this.jTableBinding.addColumnBinding(ELProperty.create("${param4}"));

    columnBinding31.setColumnName("param4");
    columnBinding31.setColumnClass(String.class);
    columnBinding31.setEditable(false);

     JTableBinding.ColumnBinding columnBinding32 = this.jTableBinding.addColumnBinding(ELProperty.create("${param5}"));

    columnBinding32.setColumnName("param5");
    columnBinding32.setColumnClass(String.class);
    columnBinding32.setEditable(false);

     JTableBinding.ColumnBinding columnBinding33 = this.jTableBinding.addColumnBinding(ELProperty.create("${descripcion}"));

    columnBinding33.setColumnName("descripcion");
    columnBinding33.setColumnClass(String.class);
    columnBinding33.setEditable(false);

     JTableBinding.ColumnBinding columnBinding34 = this.jTableBinding.addColumnBinding(ELProperty.create("${param7}"));

    columnBinding34.setColumnName("param7");
    columnBinding34.setColumnClass(String.class);
    columnBinding34.setEditable(false);

     JTableBinding.ColumnBinding columnBinding35 = this.jTableBinding.addColumnBinding(ELProperty.create("${param8}"));

    columnBinding35.setColumnName("param8");
    columnBinding35.setColumnClass(String.class);
    columnBinding35.setEditable(false);

     JTableBinding.ColumnBinding columnBinding36 = this.jTableBinding.addColumnBinding(ELProperty.create("${cont_familiar}"));

    columnBinding36.setColumnName("cont_familiar");
    columnBinding36.setColumnClass(String.class);
    columnBinding36.setEditable(false);

     JTableBinding.ColumnBinding columnBinding37 = this.jTableBinding.addColumnBinding(ELProperty.create("${param9}"));

    columnBinding37.setColumnName("param9");
    columnBinding37.setColumnClass(String.class);
    columnBinding37.setEditable(false);

     JTableBinding.ColumnBinding columnBinding38 = this.jTableBinding.addColumnBinding(ELProperty.create("${fecha}"));

    columnBinding38.setColumnName("fecha");
    columnBinding38.setColumnClass(String.class);
    columnBinding38.setEditable(false);

     JTableBinding.ColumnBinding columnBinding39 = this.jTableBinding.addColumnBinding(ELProperty.create("${param10}"));

    columnBinding39.setColumnName("param10");
    columnBinding39.setColumnClass(String.class);
    columnBinding39.setEditable(false);

     JTableBinding.ColumnBinding columnBinding41 = this.jTableBinding.addColumnBinding(ELProperty.create("${paramEntero}"));

    columnBinding41.setColumnName("paramEntero");
    columnBinding41.setColumnClass(String.class);
    columnBinding41.setEditable(false);

     JTableBinding.ColumnBinding columnBinding42 = this.jTableBinding.addColumnBinding(ELProperty.create("${paramTextoLargo}"));

    columnBinding42.setColumnName("paramTextoLargo");
    columnBinding42.setColumnClass(String.class);
    columnBinding42.setEditable(false);


    this.bindingGroup.addBinding(this.jTableBinding);
    this.bindingGroup.bind();

     int[] porcentajes= {5,5,5,5,3,3,50,3,3,3,3,3,3,3,3};
         try {
            Utiles_Tabla.definirAnchoColumnasJTable(this.jTable1, porcentajes);
        } catch (Exception ex) {

        }

   }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jScrollPane1 = new javax.swing.JScrollPane();
        jTable1 = new javax.swing.JTable();
        jbtGuardar14 = new javax.swing.JButton();
        jbSalir = new javax.swing.JButton();

        setResizable(true);
        setTitle("ADMINISTRAR PARAMETROS");

        jTable1.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "ID", "PARAM1", "PARAM2", "PARAM3", "PARAM4", "PARAM5", "DESCRIPCION", "PARAM7", "PARAM8", "CONT", "PARAM9", "FECHA", "PARAM10", "PARAMENTERO", "TEXTOLARGO"
            }
        ));
        jScrollPane1.setViewportView(jTable1);

        jbtGuardar14.setFont(new java.awt.Font("Arial", 1, 12));
        jbtGuardar14.setIcon(new javax.swing.ImageIcon(getClass().getResource("/iconoscomb/16x16ozygen/actions/button_ok.png"))); // NOI18N
        jbtGuardar14.setMnemonic('A');
        jbtGuardar14.setText("MODIFICAR");
        jbtGuardar14.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtGuardar14ActionPerformed(evt);
            }
        });

        jbSalir.setFont(new java.awt.Font("Arial", 1, 12));
        jbSalir.setIcon(new javax.swing.ImageIcon(getClass().getResource("/iconoscomb/16x16ozygen/actions/button_cancel.png"))); // NOI18N
        jbSalir.setMnemonic('C');
        jbSalir.setText("CERRAR");
        jbSalir.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbSalirActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 708, Short.MAX_VALUE)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addComponent(jbtGuardar14)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jbSalir)))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 296, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jbtGuardar14)
                    .addComponent(jbSalir))
                .addContainerGap(19, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jbtGuardar14ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtGuardar14ActionPerformed
         try{
            int indice=this.jTable1.getSelectedRow();
            String auxi=jTable1.getValueAt(indice,0).toString().trim();
            jdActualizaTrataParametro dialog = new jdActualizaTrataParametro(null,auxi,this);
            dialog.setLocationRelativeTo(null);
            dialog.setPadreDetalleAlmacen(this);
            dialog.setVisible(true);

        }catch(Exception e){
        e.printStackTrace();}
    }//GEN-LAST:event_jbtGuardar14ActionPerformed

    private void jbSalirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbSalirActionPerformed
        int res = javax.swing.JOptionPane.showConfirmDialog( this,"Esta seguro de salir?",
                "Confirmar",javax.swing.JOptionPane.YES_NO_OPTION );
        if(res==javax.swing.JOptionPane.YES_OPTION){
            this.dispose();
        }
}//GEN-LAST:event_jbSalirActionPerformed


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTable jTable1;
    private javax.swing.JButton jbSalir;
    public javax.swing.JButton jbtGuardar14;
    // End of variables declaration//GEN-END:variables

}
